#include<iostream>
#include<string>
#include<math.h>
#include<iomanip>
#include<clocale>
#include "statistics.h"
#include "words.h"
#include "Watch.h"
#include "hr_time.h"


using namespace U32;
//using namespace U33;
using namespace doa_v2;
using namespace std;

namespace U31
{
	double RecFun(int n)
	{
		double sum;

		if( n <= 0)
		{
			return 0;
		}
		else if ( n == 1)
		{
			return 1;
		}
		else
		{
			sum =1 /sqrt(n) + RecFun(n-1);
			return sum;
		}
	}

	double ItvFun(int n)
	{
		double sum = 0;
		if ( n <= 0)
		{
			return 0;
		}
		for (int i = 1; i <= n; i++)
		{
			sum = sum + 1/ sqrt(i);
		}
		return sum;
	}
	void main1()
	{
		int tal;
		cout << "Ge Tal: " ;
		cin >> tal;
		cout << RecFun(tal) << endl;
	}
	void main2()
	{
		int tal;
		cout << "Ge Tal: " ;
		cin >> tal;
		cout << ItvFun(tal) << endl;
	}
}
namespace U32
{
	void main()
	{
		CStopWatch csw;
		csw.startTimer();
		{
		statistics s;
		s.ReadFromFile("salary.txt");
		cout << s.Calculate_mean() << endl;
		cout << s.percentile(25) <<endl;
		cout << s.percentile(50) <<endl;
		cout << s.percentile(75) <<endl;
		cout << s.percentile(90) <<endl;
		cout << s.percentile(99) <<endl;
		}
		csw.stopTimer();
		cout << "Tid: " << setprecision(10) << csw.getElapsedTime() <<endl;
	}
}

//namespace U33
//{
//	void main()
//	{
//		words ord;
//		ord.readfromfile("nils_holgersson.txt");
//		ord.frekventord();
//		ord.mestFrekventa();
//		ord.print();
//	}
//}
namespace U34
{
	void main()
	{
		("nils_holgersson.txt");
	}
}

int main()
{
	cout << "Recursive function! "<<endl;
	U31::main1();
	cout << "Iterative Function! "<<endl;
	U31::main2();
	cout << "Uppgift 2" << endl;
	U32::main();
	cout << "Uppgift 3" << endl;
	/*U33::main();*/
	doa_v2::main_two();
	system("pause");
}